<!--
 * @Descripttion: 出手鸭小程序
 * @version:1.0.1 
 * @Author: HHL
 * @Date: 2022-11-15 10:24:46
 * @LastEditTime: 2025-06-18 20:09:31
 * @LastEditors: sueRimn
-->
<template>
	<view class="page" :style="{ paddingTop: systemInfo.statusBarHeight + 'rpx' }">
		<view class="bg"></view>
		<!-- #ifndef H5 -->
		<logo-vue/>
		
		<!-- #endif -->
		<top-search :geoLocation="geoLocation"/>
		<!-- banner -->
		<banner-vue :list="banner"/>
		<!-- tips -->
		<!-- <tips-vue/> -->

		<!-- <nav-vue v-if="navigate && navigate.length" :list="navigate" /> -->

		<my-phone v-if="showProductInfo.productId" :showProductInfo="showProductInfo" />
		
		<!-- 服务步骤 -->
		<huishou-step/>

		<!-- 常见问题 -->
		<help-vue/>

		<!-- 公共底部 -->
		<bottom-nav type='home' />


		<!-- 微信隐私授权 -->
		<!-- #ifdef MP-WEIXIN -->
		<ws-wx-privacy ref="wxPrivacyRef" id="privacy-popup" />
		<!-- #endif -->
	</view>
</template>

<script>
import { mapGetters } from 'vuex'

import {
	getHomeData,
} from '@/api'

import productEvaluateInfo from '@/mixins/productEvaluateInfo'

import TopSearch from './components/TopSearch.vue'
import LogoVue from './components/Logo.vue'
import TipsVue from './components/Tips.vue'
import NavVue from './components/Nav.vue'
import MyPhone from './components/MyPhone.vue'
import BannerVue from './components/Banner.vue'
import HuishouStep from './components/HuishouStep'
import HelpVue from './components/Help.vue'

export default {
	name: 'Index',
	mixins: [productEvaluateInfo],
	components: {
		TopSearch, NavVue, MyPhone, BannerVue, HuishouStep,LogoVue,TipsVue,HelpVue
	},
	data() {
		return {
			statusBarHeight: 0,
			banner: [],
			navigate: [],
			article: [],
			doorServiceList: [],
		}
	},
	computed: {
		...mapGetters([
			'location', 'userInfo', 'systemInfo','geoLocation'
		])
	},
	onLoad() {
		uni.hideTabBar()
		this.loadHome()
		this.getLocation()
		this.initData()
	},

	onShow() {
		this.loadProductEvaluateInfo()
		// #ifdef MP-ALIPAY
		my.hideTabBar()
		my.hideTabBar();
		// #endif
	},

	onPullDownRefresh() {
		this.loadHome()
	},

	onShareAppMessage() {
		return {
			title: '出手鸭',
			path: '/pages/index/index',
		}
	},
	onShareTimeline() {
		return {
			title: '出手鸭',
		}
	},

	methods: {
		// 获取定位
		async getLocation() {
			let res = this.location
			if (res.code === 0) {
				res = await this.$store.dispatch('userLocation/getLocation', true)
			}
		},
  //初始化信息
  initData() {
      // #ifdef MP_ALIPAY
      my.setNavigationBar({
        backgroundColor: '#000000', // 想使用frontColor 这个字段必填
        frontColor: '#FFFFFF' // 设置文字及状态栏电量、日期等文字颜色
      })
      //#endif
    },
		// 获取首页数据
		loadHome() {
			try {
				getHomeData().then(({ data, code }) => {
					if (code === 200) {
						const {
							banner, article, navigate, serviceList,
						} = data

						this.banner = banner || []
						this.article = article || []
						this.navigate = navigate || []
						this.doorServiceList = serviceList || []
					}
				})
			} finally {
				uni.stopPullDownRefresh()
			}
		},

	}
}
</script>

<style lang="scss" scoped>
.bg{
	background: linear-gradient(180deg, #ff8103 0%, #F6F7F9 100%);
	width: 100%;
	// #ifndef H5
	height: 680rpx;
	// #endif
	// #ifdef H5
	height: 500rpx;
	// #endif
	position: fixed;
	left: 0;
	top: 0;
	bottom: 0;
	z-index: 0;
}
</style>
